package com.medicine.hbp.adapter.self;

import com.medicine.hbp.base.MyBaseAdapter;
import com.medicine.hbp.mob.DiscussInfoVo;
import com.medicine.hbp.ui.WebActivity;
import com.medicine.hbp.R;

import android.app.Activity;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;

public class SelfUserPlAdapter extends MyBaseAdapter {
	private LayoutInflater inflater;

	public SelfUserPlAdapter(Activity activity) {
		this.activity=activity;
		inflater = LayoutInflater.from(activity);
	}

	@Override
	public View getView(int position, View view, ViewGroup arg2) {
		ViewHolder holder;
		if (view == null) {
			holder = new ViewHolder();
			view = inflater.inflate(R.layout.item_pl, null);
			holder.text_user_plnr = (TextView) view.findViewById(R.id.text_user_plnr);
			holder.text_pl_time = (TextView) view.findViewById(R.id.text_pl_time);
			view.setTag(holder);
		} else {
			holder = (ViewHolder) view.getTag();
		}
		final DiscussInfoVo discussInfoVo = (DiscussInfoVo) getItem(position);
		if (discussInfoVo != null) {
			holder.text_user_plnr.setText(discussInfoVo.discussMsg);
			holder.text_pl_time .setText(discussInfoVo.discussDate);
			view.setOnClickListener(new OnClickListener() {

				@Override
				public void onClick(View arg0) {
					Intent intent = new Intent(activity, WebActivity.class);
					intent.putExtra("isCollect", discussInfoVo.article.isCollect);
					intent.putExtra("ID", discussInfoVo.article.artId);
					intent.putExtra("NAME", "文章内容详情");
					intent.putExtra("isCollect", discussInfoVo.article.isCollect);
					activity.startActivity(intent);

				}
			});
		}
		return view;
	}

	class ViewHolder {
		TextView text_user_plnr;
		TextView  text_pl_time;
	}

}
